package com.ymatou.iapi.payment.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.payment.parameter.CreateFqlCreditApplyBean;
import com.ymatou.iapi.payment.service.CreateFqlCreditApplyCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.FqlCreditApply;
import com.ymttest.database.sqlwapper.PayGateWayWapper;
import com.ymttest.utils.TestDataManager;
/**
*分期乐创建授信单
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CreateFqlCreditApply{
	private static CreateFqlCreditApplyBean createfqlcreditapplyBean;
	private static CreateFqlCreditApplyCall createfqlcreditapplyCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("分期乐创建授信单");
	}

	@Before
	public void caseUp() {
		createfqlcreditapplyBean=new CreateFqlCreditApplyBean();
		createfqlcreditapplyCall=new CreateFqlCreditApplyCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(createfqlcreditapplyCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_CreateFqlCreditApply_001() {
		Logger.start(true,"分期乐创建授信单成功");
		try {
			createfqlcreditapplyBean.setDegree(1);
			createfqlcreditapplyBean.setFqlToken("token");
			createfqlcreditapplyBean.setIdentity(TestDataManager.getCardId(70, 2));
			createfqlcreditapplyBean.setIdentityFrontUrl("http://p2.ifengimg.com/cmpp/2016/08/12/06/21513462-b89d-408f-a933-06514e0e4d06_size124_w400_h509.jpg");
			createfqlcreditapplyBean.setIdentityReverseUrl("http://p2.ifengimg.com/cmpp/2016/08/12/06/21513462-b89d-408f-a933-06514e0e4d06_size124_w400_h509.jpg");
			createfqlcreditapplyBean.setMobile("19999999999"); 
			createfqlcreditapplyBean.setName(TestDataManager.getChineseName());
			createfqlcreditapplyBean.setUserId(25328855);
			createfqlcreditapplyBean.setWork(1);
			createfqlcreditapplyBean.setScene(2);
			createfqlcreditapplyCall.setData(createfqlcreditapplyBean);
			createfqlcreditapplyCall.callService();			
			
			FqlCreditApply fqlca = new PayGateWayWapper().selectFqlCreditApplyByUserId(createfqlcreditapplyBean.getUserId()).get(0);
			Logger.debug(FormatUtil.beanToGSONString(fqlca));
			Logger.verifyEquals(createfqlcreditapplyBean.getDegree(), fqlca.getDegree(), "Degree");
			Logger.verifyEquals(createfqlcreditapplyBean.getIdentity(), fqlca.getIdentity(), "Identity");
			Logger.verifyEquals(createfqlcreditapplyBean.getIdentityFrontUrl(), fqlca.getIdentityFrontUrl(), "IdentityFrontUrl");
			Logger.verifyEquals(createfqlcreditapplyBean.getIdentityReverseUrl(), fqlca.getIdentityReverseUrl(), "IdentityReverseUrl");
			Logger.verifyEquals(createfqlcreditapplyBean.getMobile(), fqlca.getMobile(), "Mobile");
			Logger.verifyEquals(createfqlcreditapplyBean.getName(), fqlca.getName(), "Name");
			Logger.verifyEquals(createfqlcreditapplyBean.getWork(), fqlca.getWork(), "Work");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}